home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / mm / exec.c.D < prev    next >
Text File  |  1990-07-25  |  8KB  |  262 lines

  1. *** /tmp/,RCSt1022399    Wed Jul 25 13:59:41 1990
  2. --- exec.c    Mon Jul 23 16:16:34 1990
  3. ***************
  4. *** 14,22 ****
  5.   
  6. ! #include "../h/const.h"
  7. ! #include "../h/type.h"
  8. ! #include "../h/callnr.h"
  9. ! #include "../h/error.h"
  10. ! #include "../h/stat.h"
  11. ! #include "const.h"
  12. ! #include "glo.h"
  13.   #include "mproc.h"
  14. --- 14,18 ----
  15.   
  16. ! #include "mm.h"
  17. ! #include <sys/stat.h>
  18. ! #include <minix/callnr.h>
  19.   #include "mproc.h"
  20. ***************
  21. *** 24,26 ****
  22. --- 20,26 ----
  23.   
  24. + #if INTEL_32BITS
  25. + #define MAGIC    0x10000301L
  26. + #else
  27.   #define MAGIC    0x04000301L    /* magic number with 2 bits masked off */
  28. + #endif
  29.   #define SEP      0x00200000L    /* value for separate I & D */
  30. ***************
  31. *** 32,35 ****
  32.   
  33. ! #ifdef ATARI_ST
  34. ! PUBLIC long lseek();
  35.   #endif
  36. --- 32,40 ----
  37.   
  38. ! FORWARD void load_seg();
  39. ! FORWARD int new_mem();
  40. ! FORWARD void patch_ptr();
  41. ! FORWARD int read_header();
  42. ! #if (CHIP == M68000)
  43. ! FORWARD int relocate();
  44.   #endif
  45. ***************
  46. *** 48,52 ****
  47.     int m, r, fd, ft;
  48. !   char mbuf[MAX_ISTACK_BYTES];    /* buffer for stack and zeroes */
  49.     union u {
  50. !     char name_buf[MAX_PATH];    /* the name of the file to exec */
  51.       char zb[ZEROBUF_SIZE];    /* used to zero bss */
  52. --- 53,57 ----
  53.     int m, r, fd, ft;
  54. !   char mbuf[ARG_MAX];    /* buffer for stack and zeroes */
  55.     union u {
  56. !     char name_buf[PATH_MAX];/* the name of the file to exec */
  57.       char zb[ZEROBUF_SIZE];    /* used to zero bss */
  58. ***************
  59. *** 63,66 ****
  60.     stk_bytes = (vir_bytes) stack_bytes;
  61. !   if (stk_bytes > MAX_ISTACK_BYTES) return(ENOMEM);    /* stack too big */
  62. !   if (exec_len <= 0 || exec_len > MAX_PATH) return(EINVAL);
  63.   
  64. --- 68,71 ----
  65.     stk_bytes = (vir_bytes) stack_bytes;
  66. !   if (stk_bytes > ARG_MAX) return(ENOMEM);    /* stack too big */
  67. !   if (exec_len <= 0 || exec_len > PATH_MAX) return(EINVAL);
  68.   
  69. ***************
  70. *** 78,80 ****
  71.     sc = (stk_bytes + CLICK_SIZE - 1) >> CLICK_SHIFT;
  72. !   m = read_header(fd, &ft, &text_bytes, &data_bytes, &bss_bytes, &tot_bytes, &sym_bytes, sc);
  73.     if (m < 0) {
  74. --- 83,86 ----
  75.     sc = (stk_bytes + CLICK_SIZE - 1) >> CLICK_SHIFT;
  76. !   m = read_header(fd, &ft, &text_bytes, &data_bytes, &bss_bytes, 
  77. !                         &tot_bytes, &sym_bytes, sc);
  78.     if (m < 0) {
  79. ***************
  80. *** 113,115 ****
  81.     load_seg(fd, D, data_bytes);
  82. ! #ifdef ATARI_ST
  83.     if (lseek(fd, sym_bytes, 1) < 0)
  84. --- 119,121 ----
  85.     load_seg(fd, D, data_bytes);
  86. ! #if (CHIP == M68000)
  87.     if (lseek(fd, sym_bytes, 1) < 0)
  88. ***************
  89. *** 122,131 ****
  90.     /* Take care of setuid/setgid bits. */
  91. !   if (s_buf.st_mode & I_SET_UID_BIT) {
  92. !     rmp->mp_effuid = s_buf.st_uid;
  93. !     tell_fs(SETUID, who, (int) rmp->mp_realuid, (int) rmp->mp_effuid);
  94.     }
  95. -   if (s_buf.st_mode & I_SET_GID_BIT) {
  96. -     rmp->mp_effgid = s_buf.st_gid;
  97. -     tell_fs(SETGID, who, (int) rmp->mp_realgid, (int) rmp->mp_effgid);
  98. -   }
  99.   
  100. --- 128,139 ----
  101.     /* Take care of setuid/setgid bits. */
  102. !   if ((rmp->mp_flags & TRACED) == 0) { /* suppress if tracing */
  103. !     if (s_buf.st_mode & I_SET_UID_BIT) {
  104. !         rmp->mp_effuid = s_buf.st_uid;
  105. !         tell_fs(SETUID, who, (int) rmp->mp_realuid, (int) rmp->mp_effuid);
  106. !     }
  107. !     if (s_buf.st_mode & I_SET_GID_BIT) {
  108. !         rmp->mp_effgid = s_buf.st_gid;
  109. !         tell_fs(SETGID, who, (int) rmp->mp_realgid, (int) rmp->mp_effgid);
  110. !     }
  111.     }
  112.   
  113. ***************
  114. *** 136,138 ****
  115.     new_sp = (char *) vsp;
  116. !   sys_exec(who, new_sp);
  117.     return(OK);
  118. --- 144,146 ----
  119.     new_sp = (char *) vsp;
  120. !   sys_exec(who, new_sp, rmp->mp_flags & TRACED);
  121.     return(OK);
  122. ***************
  123. *** 144,146 ****
  124.    *===========================================================================*/
  125. ! PRIVATE int read_header(fd, ft, text_bytes, data_bytes, bss_bytes, tot_bytes, sym_bytes, sc)
  126.   int fd;                /* file descriptor for reading exec file */
  127. --- 152,155 ----
  128.    *===========================================================================*/
  129. ! PRIVATE int read_header(fd, ft, text_bytes, data_bytes, bss_bytes, 
  130. !                             tot_bytes, sym_bytes, sc)
  131.   int fd;                /* file descriptor for reading exec file */
  132. ***************
  133. *** 171,180 ****
  134.      *    7: size of symbol table in bytes
  135. ! #ifdef i8088
  136. !    * The longs are represented low-order byte first and high-order byte last.
  137. !    * The first byte of the header is always 0x01, followed by 0x03.
  138. ! #endif
  139. ! #ifdef ATARI_ST
  140. !    * The longs are represented high-order byte first and low-order byte last.
  141. !    * The third byte of the header is always 0x03, followed by 0x01.
  142. ! #endif
  143.      * The header is followed directly by the text and data segments, whose sizes
  144. --- 180,183 ----
  145.      *    7: size of symbol table in bytes
  146. !    * The longs are represented in a machine dependent order,
  147. !    * little-endian on the 8088, big-endian on the 68000.
  148.      * The header is followed directly by the text and data segments, whose sizes
  149. ***************
  150. *** 196,198 ****
  151.     if (*ft != SEPARATE) {
  152. ! #ifndef ATARI_ST
  153.       /* If I & D space is not separated, it is all considered data. Text=0 */
  154. --- 199,201 ----
  155.     if (*ft != SEPARATE) {
  156. ! #if (CHIP != M68000)
  157.       /* If I & D space is not separated, it is all considered data. Text=0 */
  158. ***************
  159. *** 252,256 ****
  160.     phys_clicks new_base;
  161. !   extern phys_clicks alloc_mem();
  162. !   extern phys_clicks max_hole();
  163. ! #ifdef ATARI_ST
  164.     phys_clicks base, size;
  165. --- 255,257 ----
  166.     phys_clicks new_base;
  167. ! #if (CHIP == M68000)
  168.     phys_clicks base, size;
  169. ***************
  170. *** 283,285 ****
  171.     rmp = mp;
  172. ! #ifndef ATARI_ST
  173.     old_clicks = (phys_clicks) rmp->mp_seg[S].mem_len;
  174. --- 284,286 ----
  175.     rmp = mp;
  176. ! #if (CHIP != M68000)
  177.     old_clicks = (phys_clicks) rmp->mp_seg[S].mem_len;
  178. ***************
  179. *** 301,303 ****
  180.     rmp->mp_seg[S].mem_phys = rmp->mp_seg[D].mem_phys + data_clicks + gap_clicks;
  181. ! #ifdef ATARI_ST
  182.     rmp->mp_seg[T].mem_vir = rmp->mp_seg[T].mem_phys;
  183. --- 302,304 ----
  184.     rmp->mp_seg[S].mem_phys = rmp->mp_seg[D].mem_phys + data_clicks + gap_clicks;
  185. ! #if (CHIP == M68000)
  186.     rmp->mp_seg[T].mem_vir = rmp->mp_seg[T].mem_phys;
  187. ***************
  188. *** 310,312 ****
  189.   #endif
  190. ! #ifdef ATARI_ST
  191.     sys_fresh(who, rmp->mp_seg, (phys_clicks)(data_bytes >> CLICK_SHIFT),
  192. --- 311,313 ----
  193.   #endif
  194. ! #if (CHIP == M68000)
  195.     sys_fresh(who, rmp->mp_seg, (phys_clicks)(data_bytes >> CLICK_SHIFT),
  196. ***************
  197. *** 342,345 ****
  198.    *===========================================================================*/
  199. ! PRIVATE patch_ptr(stack, base)
  200. ! char stack[MAX_ISTACK_BYTES];    /* pointer to stack image within MM */
  201.   vir_bytes base;            /* virtual address of stack base inside user */
  202. --- 343,346 ----
  203.    *===========================================================================*/
  204. ! PRIVATE void patch_ptr(stack, base)
  205. ! char stack[ARG_MAX];    /* pointer to stack image within MM */
  206.   vir_bytes base;            /* virtual address of stack base inside user */
  207. ***************
  208. *** 359,361 ****
  209.     while (flag < 2) {
  210. !     if (ap >= (char **) &stack[MAX_ISTACK_BYTES]) return;    /* too bad */
  211.       if (*ap != NIL_PTR) {
  212. --- 360,362 ----
  213.     while (flag < 2) {
  214. !     if (ap >= (char **) &stack[ARG_MAX]) return;    /* too bad */
  215.       if (*ap != NIL_PTR) {
  216. ***************
  217. *** 375,377 ****
  218.    *===========================================================================*/
  219. ! PRIVATE load_seg(fd, seg, seg_bytes)
  220.   int fd;                /* file descriptor to read from */
  221. --- 376,378 ----
  222.    *===========================================================================*/
  223. ! PRIVATE void load_seg(fd, seg, seg_bytes)
  224.   int fd;                /* file descriptor to read from */
  225. ***************
  226. *** 396,398 ****
  227.     while (seg_bytes) {
  228. !     bytes = 16*1024;        /* could be 32767 */
  229.       if (seg_bytes < bytes)
  230. --- 397,399 ----
  231.     while (seg_bytes) {
  232. !     bytes = 31*1024;        /* <= 32767 */
  233.       if (seg_bytes < bytes)
  234. ***************
  235. *** 406,408 ****
  236.   
  237. ! #ifdef ATARI_ST
  238.   /*===========================================================================*
  239. --- 407,409 ----
  240.   
  241. ! #if (CHIP == M68000)
  242.   /*===========================================================================*
  243. ***************
  244. *** 443,445 ****
  245.     p = buf;
  246. !   n = read(fd, p, MAX_ISTACK_BYTES);
  247.     if (n < sizeof(long))
  248. --- 444,446 ----
  249.     p = buf;
  250. !   n = read(fd, p, ARG_MAX);
  251.     if (n < sizeof(long))
  252. ***************
  253. *** 457,459 ****
  254.               p = buf;
  255. !             n = read(fd, p, MAX_ISTACK_BYTES);
  256.               if (--n < 0)
  257. --- 45